package com.knight.study.patterns.tujie.prototype;

/**
 * @Author knight
 * @Date 2024/9/10 16:19
 */

public class PrototypeMains {
    public static void main(String[] args) {
        Manager manager = new Manager();
        final UnderLinePen upen = new UnderLinePen('-');
        final MessageBox mbox = new MessageBox('*');
        final MessageBox sbox = new MessageBox('/');
        manager.register("strong", upen);
        manager.register("warning", mbox);
        manager.register("slash", sbox);

        final Product strong = manager.create("strong");
        strong.use("hello,world.");

        upen.createClone().createClone().createClone().createClone().use("hello,world.5");
        upen.use("hello,puli.");
        upen.use("hello,puli2.");
    }

    private static void checkEqu(){
        //相比box2 = mbox，clone方式是新的实例
        MessageBox mbox = new MessageBox('*');
        final char decochar = mbox.getDecochar();
        System.out.println(decochar);

        MessageBox box = (MessageBox) mbox.createClone();
        box.setDecochar('-');
        System.out.println(mbox.getDecochar());
        System.out.println(box.getDecochar());

        MessageBox box2 = mbox;
        box2.setDecochar('=');
        System.out.println(mbox.getDecochar());
        System.out.println(box2.getDecochar());
    }
}
